package kamkor.ann.namerecog.network.parser

import scala.collection.mutable.HashMap

/**
 * 
 * @author kamkor
 *
 */
object ArgsParser {
	val mapKey = "map"
	val trainingDataKey = "trainingData"
	val startIndexKey = "sIndex" 
	val stepKey = "step"
	val maxSurnameLengthKey = "maxSurnameLength"
	val hiddenLayerNeuronsKey = "hNeurons"
	val epochsKey = "epochs"
	val errorKey = "error"
	
	def parseArgs(args: Array[String]): HashMap[String, String] = {
		require(args.length == 8, println("8 arguments are required"))
		val argTuples =
			for (arg <- args) yield {
				val argSplitted = arg.split("=")
				argSplitted(0) -> argSplitted(1)
			}
		
		val argsMap = new HashMap[String, String]()
		for (arg <- argTuples) {
			argsMap += arg
		}
		require(argsMap.contains(mapKey), println("map arg is missing"))
		require(argsMap.contains(trainingDataKey), println("trainingData arg is missing"))
		require(argsMap.contains(startIndexKey), println("sIndex arg is missing"))
		require(argsMap.contains(stepKey), println("step arg is missing"))
		require(argsMap.contains(maxSurnameLengthKey), println("maxSurnameLength arg is missing"))
		require(argsMap.contains(hiddenLayerNeuronsKey), println("hNeurons arg is missing"))
		require(argsMap.contains(epochsKey), println("epochs arg is missing"))
		require(argsMap.contains(errorKey), println("error arg is missing"))		
		argsMap
	}
}